package com.tech.servcie.impl;

import com.tech.UserDao;
import com.tech.impl.UserDaoImpl;
import com.tech.servcie.UserServcie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 业务层实现类
 */

// <bean id="userService" class="com.tech.servcie.impl.UserServiceImpl">
@Service("userService")
public class UserServiceImpl implements UserServcie {


//    @Autowired
//    @Qualifier("userDao")

    @Resource(name = "userDao")
    private UserDao userDao;

//    public void setData(UserDao userDao) {
//        this.userDao = userDao;
//    }


    public UserServiceImpl(UserDao info) {
        this.userDao = info;
    }

    public void save() {
        //调用 dao层面
//        ClassPathXmlApplicationContext app = new ClassPathXmlApplicationContext("ApplicationContext.xml");
//        UserDao userDao = (UserDao) app.getBean("userDao");
        userDao.save();
    }
}
